package com.itheima02.string;

public class String_StringBuilder_Demo1 {

    public static void main(String[] args) {
        //583
        /*long start = System.currentTimeMillis(); //开始时间
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= 5000000; i++) {
            sb.append(i);

        }
        System.out.println(sb);
        long end = System.currentTimeMillis();//结束时间
        System.out.println(end - start);*/
        getStringResult();
    }

    private static void getStringResult() {
        long start = System.currentTimeMillis(); //开始时间
        String s = "";
        for (int i = 1; i <= 5000000; i++) {
            // 30452毫秒
            s += i;
        }
        System.out.println(s);
        long end = System.currentTimeMillis();//结束时间
        System.out.println(end - start);
    }
}
